<template>
  <div>
    <div style="width:100%;background-color: #FFFFFF;">
      <a-tabs :activeKey="defaultActiveKey" @change="callback" size="small">
        <a-tab-pane key="1" tab="综合评估" forceRender>
<!--          <care rel="prefetch" ref="care"></care>-->
          <pulldown header="季度评估">
            <div slot="content">
              <RecordList ref="RecordList1"></RecordList>
            </div>
          </pulldown>
          <pulldown header="年度评估">
            <div slot="content">
              <RecordList ref="RecordList2"></RecordList>
            </div>
          </pulldown>
        </a-tab-pane>
        <a-tab-pane key="2" tab="风险等级评估" forceRender>
          <z-table
            ref="table"
            rowKey="id"
            :showAlert="false"
            :showSelection="true"
            :loading="loading"
            :columns="columns"
            :dataSource="pageData"
            @change="onTableChange"
          >
            <template slot="action" slot-scope="text, record">
              <a :href="text"></a>
            </template>
          </z-table>
        </a-tab-pane>
      </a-tabs>
    </div>
  </div>

</template>

<script>
import pulldown from '../../modules/pulldown'
import RecordList from "@views/sjsk/holographicArchives/modules/RecordList";
import * as serviceApi from "@api/sjsk/clinicmanageService";
// import care from '@views/sjsk/holographicArchives/modules/estimate/care'
// import serve from "@views/sjsk/holographicArchives/modules/estimate/serve";
export default {
  name: "index",
  components:{pulldown,RecordList},
  data(){
    return {
      innse:true,
      defaultActiveKey:'1',
      loading: false,
      columns: [

        {
          title: '风险等级',
          dataIndex: 'currentRiskLevel',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={this.$filterDictTextByCache('risk_category', text)} length={14} />
          }
        },
        {
          title: '评估周期',
          dataIndex: 'evalCycle',
          width: 80,
          align: 'center'
        },
        {
          title: '管辖地区',
          dataIndex: 'householdTown',
          width: 110,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '评估状态',
          dataIndex: 'status',
          width: 110,
          align: 'center',
          customRender: (text, record, index) => {
            return text==0? '待评估': text==1? '待审批': text==2? '审批中':text==3? '完成':text==4? '驳回':text==5? '撤销':'--'
          }
        },
        {
          title: '附件',
          width: 60,
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        }
      ],
      pageData: {}
    }
  },
  mounted() {
    console.log(3)

  },
  methods:{
    refreshTable(){
      console.log('预估')
      this.callback('1')
      // this.callback('2')
      let dataParam = {
        sources:'1'
      }
      let queryParam = Object.assign({}, dataParam, this.pageFilter)
      serviceApi
        .getPageNewRiskLevelEval1(queryParam)
        .then(res => {
          this.loading = false
          this.pageData = res.result ? res.result : {}
          this.$refs.table.onClearRowKeys()
          if(!res.success) this.$message.warn(res.message?res.message:'请求失败')
        })
        .catch(e => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    onTableChange(pagination, pageFilter, sorter) {
      this.pageFilter = Object.assign({}, this.pageFilter, pagination)
      this.refreshTable()
    },
    callback(key) {
      console.log(key)
      switch(key){
        case '1':
          this.$refs.RecordList1.refreshTable()
          this.defaultActiveKey = '1'
          break
        case '2':
          this.$refs.RecordList2.refreshTable()
          this.defaultActiveKey = '2'
          break
      }
    },
  }
}
</script>

<style scoped>

</style>